package leetcode.editor.cn;

import java.util.*;
import leetcode.editor.common.*;

public class SingleNumber {

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int singleNumber(int[] nums) {
            // 非空
            if(nums==null|| nums.length==0){
                return -1;
            }

            Set alreadySet= new HashSet<Integer>();
            for(int i =0;i<nums.length;i++){
                if(alreadySet.contains(nums[i])){
                      return nums[i];
                }
            alreadySet.add(nums[i]);

            }
            return -1;
        }
    }
    //leetcode submit region end(Prohibit modification and deletion)

    
    public static void main(String[] args) {
        Solution solution = new SingleNumber().new Solution();
        // put your test code here
        
    }
}
